
package jweslley.ContestVolumes.VolumeCVII;

import static java.lang.Math.ceil;
import static java.lang.Math.sqrt;

import java.util.Scanner;

import jweslley.Problem;
import jweslley.Problem.Status;

/**
 * http://icpcres.ecs.baylor.edu/onlinejudge/external/107/10784.html
 *
 * @author  Jonhnny Weslley
 * @version 1.00, 21/10/2008
 */
@Problem(Status.Accepted)
public class Diagonal {

	public static void main(String[] args) {
		StringBuilder out = new StringBuilder();
		Scanner in = new Scanner(System.in);
		long n; int counter = 1;		
		while ((n = in.nextLong()) != 0) {
			out
			.append(String.format("Case %s: %s\n", counter++, (int)ceil((3 + sqrt(9 + 8*n))/2)));
		}
		System.out.print(out);
	}

}
